package de.koller.worlders.engine.tiles.landscape.generator;

import de.koller.oceanFramework.gl.util.ImagePreview;
import de.koller.worlders.engine.util.tilebased.LineWay;
import de.koller.worlders.engine.util.tilebased.TilePos;
import java.awt.image.BufferedImage;
import java.util.Set;

public class Island implements IGenType {

	@Override
	public BufferedImage generateLight() {
		return new BufferedImage( 30, 15, BufferedImage.TYPE_INT_ARGB );
	}

	@Override
	public BufferedImage generateMap() {
		BufferedImage bi = new BufferedImage( 100, 50, BufferedImage.TYPE_INT_ARGB );
		float rd = 10;
		for( float a = 0; a < 360; a += rd ) {
			float r = (float)Math.toRadians( a );
			float rl = (float)Math.toRadians( a - rd );
			float x = (float)Math.cos( r ) * 24.5f + 50.5f;
			float y = (float)Math.sin( r ) * 24.5f + 25.5f;
			float xl = (float)Math.cos( rl ) * 24.5f + 50.5f;
			float yl = (float)Math.sin( rl ) * 24.5f + 25.5f;
			
			Set<TilePos> t = LineWay.allTilesOnLine( x, y, xl, yl );
			for( TilePos tp : t ) {
				bi.setRGB( tp.tx, tp.ty, 0xffff0000 );
			}
		}
		return bi;
	}

	public static void main( String[] args ) {
		ImagePreview.showImage( new Island().generateMap(), 1000, 500 );
	}
	
}
